import {
  getTimestamp,
  filterTimeHMS
} from './time'

const Data = class Data {
  constructor(props) {
    this.size = props.size;
    this.page = props.page;
    this.time = props.time;
    this.channel = props.channel
    this.marketName = props.marketName
    this.os = props.os;
  }
  getState() {
    let x = {}
    //日期
    if (this.time == '') {
      x.startTime = new Date(new Date().setHours(0, 0, 0, 0)).getTime() - 29 * 24 * 60 * 60 * 1000;
      x.endTime = new Date(new Date().setHours(23, 59, 59, 999)).getTime();
    } else {
      x.startTime = this.time ? getTimestamp(this.time[0]) : undefined
      x.endTime = this.time ? getTimestamp(this.time[1]) + 86399999 : undefined
    }
    //渠道
    if (this.channel) {
      if (this.channel.length != 0) {
        x.channel = this.channel.join(',')
      }
    }
    if (this.marketName) {
      x.marketName = this.marketName
    }
    if (this.os) {
      x.os = this.os
    }
    x.size = this.size;
    x.page = this.page;
    return x;
  }
};

export default Data
